////////////////////////////////////////////////////////////////////////////////
//
//  Copyright
//
////////////////////////////////////////////////////////////////////////////////

package ru.goodcore.utils
{

import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;

/**
 * @author					Dimarik
 * @version					1.0
 * @playerversion			Flash 9
 * @langversion				3.0
 * 
 * @keyword					
 */
public final class DisplayListInspector extends Sprite {

	//-------------------------------------------------------------------------
	//
	//  Private constants
	//
	//-------------------------------------------------------------------------

	//-------------------------------------------------------------------------
	//
	//  Constructor
	//
	//-------------------------------------------------------------------------

	/**
	 * Constructor.
	 */
	public function DisplayListInspector() {
		super();
	}
	
	//--------------------------------------------------------------------------
	//
	//  Private variblies
	//
	//--------------------------------------------------------------------------

	/**
	 * @private
	 * The root of display list tree
	 */	
	private var _root:	DisplayObject;

	//-------------------------------------------------------------------------
	//
	//  Public methods
	//
	//-------------------------------------------------------------------------

	public function setInspectee(value:DisplayObject):void {
		this._root = value;
		
		this.inspect(value);
	}

	//-------------------------------------------------------------------------
	//
	//  Private methods
	//
	//-------------------------------------------------------------------------
	
	private function inspect(value:DisplayObject, deep:uint = 0):void {
		var prettyTab:	String = '';

		for (var i:uint = 0; i < deep; i++)
			prettyTab += '\t';
		
		var child:	DisplayObject;

		trace(prettyTab, value);

		if (value is DisplayObjectContainer) {
			var parent:	DisplayObjectContainer = value as DisplayObjectContainer;
			i = parent.numChildren;

			while (--i >= 0) {
				child = parent.getChildAt(i);
				
				this.inspect(child, deep + 1);
			}
		}
	}

	//-------------------------------------------------------------------------
	//
	//  DisplayObjects
	//
	//-------------------------------------------------------------------------

	//--------------------------------------------------------------------------
	//
	//  Variblies
	//
	//--------------------------------------------------------------------------

	//-------------------------------------------------------------------------
	//
	//  Override properties: DisplayObject
	//
	//-------------------------------------------------------------------------


	//-------------------------------------------------------------------------
	//
	//  Event handlers
	//
	//-------------------------------------------------------------------------


}
}